Skip to content

wrap-java: Import deprecated and requires-api annotations#587

Merged
ktoso merged 3 commits intoswiftlang:mainfrom
ktoso:annotations
Mar 6, 2026
Merged

wrap-java: Import deprecated and requires-api annotations#587
ktoso merged 3 commits intoswiftlang:mainfrom
ktoso:annotations

Conversation

@ktoso
Copy link
Collaborator

@ktoso ktoso commented Mar 6, 2026

We now handle Java Deprecated and also Android's RequiresApi annotations and import them as availability annotations on Swift side.

The Android availability requires at least Swift 6.3

resolves #586

Claude assisted boilerplate and tests; refactored a bit how we do ThreadSafe as well, there's a new enum for "known" java annotations

Methods end up as

@available(*, deprecated)
  #if compiler(>=6.3)
  @available(Android 28 /* Pie */, *)
  #endif
  @JavaMethod
  open func oldApi28Method()

need to do the compiler check since Android availability is only since 6.3.

@colemancda Would love to see https://github.com/PureSwift/Android/ re-generated with these :-)

ktoso added 3 commits March 6, 2026 10:13
We now handle Java Deprecated and also Android's RequiresApi annotations
and import them as availability annotations on Swift side.

The Android availability requires at least Swift 6.3

resolves swiftlang#586
@ktoso ktoso changed the title wrap-java: Import deprecated and requires-api wrap-java: Import deprecated and requires-api annotations Mar 6, 2026
var lines: [String] = []
for attr in attributes {
if let (major, minor) = attr.minimumCompilerVersion {
lines.append("#if compiler(>=\(major).\(minor))")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's the right check we need

@ktoso ktoso merged commit f0d2962 into swiftlang:main Mar 6, 2026
61 checks passed
@ktoso ktoso deleted the annotations branch March 6, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Carry over Java @RequiresApi and @Deprecated annotations to generated Swift JNI code

1 participant